home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / zipper.com / ZIPLIST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-05-02  |  2.2 KB  |  123 lines

  1.  
  2.  
  3.  
  4. Program ZipList;
  5.  
  6.  
  7.  
  8. {*****************************************************************************
  9.  
  10.                  Example program for use with ZIPPER.PAS.
  11.  
  12.   NOTE: Most of the Zipper routines were written with pointers in mind,
  13.         assuming that a program would want to process ZIP entryies via
  14.         linked lists (or some other dynamic data structure). In this
  15.         test code, you notice that I used a static data structure (Zrec)
  16.         and passed to other procedures as @Zrec. Sorry for the confusion.
  17.  
  18.  
  19.                 Public Domain May 2, 1989, by Tom Guinther
  20.  
  21. *****************************************************************************}
  22.  
  23.  
  24.  
  25.  
  26.  
  27. Uses
  28.   Zipper;
  29.  
  30.  
  31. Const
  32.   CompMethodStr : Array[0..5] of String = ('No Compression','Shrunk','Reduced (CF=1)',
  33.                                         'Reduced (CF=2)','Reduced (CF=3)','Reduced (CF=5)');
  34.  
  35.  
  36.  
  37. Function Pad(S : String; Len : Byte) : String;
  38. Begin
  39.  
  40.      While Length(S) < Len Do
  41.         S := S + ' ';
  42.  
  43.      Pad := S;
  44.  
  45. End;
  46.  
  47.  
  48. Procedure Header;
  49. Begin
  50.  
  51.      Writeln;
  52.  
  53.      Writeln('File name       Normal    Compressed    Factor   Compression Method');
  54.  
  55.      Writeln;
  56.  
  57. End;
  58.  
  59.  
  60.  
  61. Procedure  ShowFile(pZ : pZipDir);
  62. Begin
  63.  
  64.  
  65.    With pZ^, pCD^, FileInfo Do
  66.    Begin
  67.  
  68.      Write(Pad(MakeFileName(pZ),12),UnCompSize:10,CompSize:12);
  69.      Write(100-((CompSize/UnCompSize)*100):10:0,'%');
  70.      Writeln('        ',CompMethodStr[CompMethod]);
  71.  
  72.    End;
  73.  
  74. End;
  75.  
  76.  
  77.  
  78. Var
  79.   zF   : zFile;
  80.   Zrec : ZipDirRec;
  81.  
  82.  
  83. Begin
  84.  
  85.         If ParamCount <> 1 Then
  86.         Begin
  87.  
  88.           Writeln;
  89.           Writeln('Usage: ZipList <FILENAME.ZIP>');
  90.           Halt;
  91.  
  92.         End;
  93.  
  94.  
  95.         If NOT OpenZip(zF,ParamStr(1)) then
  96.         Begin
  97.  
  98.           Writeln('Unable to open: ',ParamStr(1));
  99.           Exit;
  100.  
  101.         End;
  102.  
  103.         If FindCentralDirectory(zF) <> 0 Then
  104.         Begin
  105.  
  106.            Header;
  107.  
  108.            While ReadCentralDirEntry(zF,@ZRec) Do
  109.            Begin
  110.  
  111.              ShowFile(@Zrec);
  112.              FreeZipRec(@ZRec);
  113.  
  114.            End;
  115.  
  116.         End
  117.         Else
  118.           Writeln(ParamStr(1)+': Unable to find ZIP directory.');
  119.  
  120.         Close(zF);
  121.  
  122. End.
  123.